package com.youhp.spire.xls.demo.Data;

import com.spire.xls.*;
import com.spire.xls.core.*;

public class NamedRanges {
    public static void main(String[] args) {

        Workbook workbook = new Workbook();
        workbook.loadFromFile("data/NamedRanges.xlsx");
        Worksheet sheet = workbook.getWorksheets().get(0);
        //Creating a named range
        INamedRange NamedRange = workbook.getNameRanges().add("NewNamedRange");
        //Setting the range of the named range
        NamedRange.setRefersToRange(sheet.getCellRange("A8:E12"));
        workbook.saveToFile("output/NamedRanges.xlsx", ExcelVersion.Version2013);
    }
}
